package com.example.baguwen.repository;

import com.example.baguwen.entity.Baguwen;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

@Repository
public interface BaguwenRepository extends JpaRepository<Baguwen, Long> {
    
    Page<Baguwen> findByType(String type, Pageable pageable);
    
    @Query("SELECT b FROM Baguwen b WHERE b.question LIKE %:keyword% OR b.content LIKE %:keyword%")
    Page<Baguwen> searchByKeyword(@Param("keyword") String keyword, Pageable pageable);
    
} 